//
//  ViewController.m
//  3.2练习4
//
//  Created by student on 16/3/2.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"
// 定义之后可以不用带mas_前缀
#define MAS_SHORTHAND
// 定义之后equalTo等于mas_equalTo
#define MAS_SHORTHAND_GLOBALS

#import "Masonry.h"
@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self test1];
    [self test2];
    
}
-(void)test1
{
    UIView *blueView = [[UIView alloc]init];
    blueView.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blueView];
    [blueView mas_makeConstraints:^(MASConstraintMaker *make){
//        make.width.equalTo(@100);
        make.height.equalTo(@40);
     
        make.left.equalTo(self.view.mas_left).offset(20);
        make.bottom.equalTo(self.view.mas_bottom).offset(-20);
    }];
    UIView *redView=[[UIView alloc]init];
    redView.backgroundColor=[UIColor redColor];
    [self.view addSubview:redView];
    [redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(blueView.width);
        make.height.equalTo(@40);
        make.left.equalTo(blueView.mas_right).offset(20);
        make.right.equalTo(self.view.mas_right).offset(-20);
        make.bottom.equalTo(self.view.mas_bottom).offset(-20);
        
    }];


}
-(void)test2
{
    UIView *blueView2 = [[UIView alloc]init];
    blueView2.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blueView2];
    [blueView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@40);
        make.left.equalTo(self.view.mas_left).offset(20);
        make.right.equalTo(self.view.mas_right).offset(-20);
        make.top.equalTo(self.view.mas_top).offset(20);
    }];
    
    UIView *redView2 = [[UIView alloc]init];
    redView2.backgroundColor = [UIColor redColor];
    [self.view addSubview:redView2];
    [redView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.view).multipliedBy(0.5).offset(-20);
        make.height.equalTo(blueView2.height);
        make.top.equalTo(blueView2.mas_bottom).offset(20);
        make.right.equalTo(blueView2.mas_right);
        
        
    }];
    
}
@end
